package csw;

import java.util.Scanner;

public class J13Ex46CalendarV1 {

	public static void main(String[] args) {
		int year = 0;
		int month = 0;
		 int myday;
		 int cyear = 1;
		 int allday = 365;
		 int leapyear = 0;
	
		//int cyear = 2003;
		//int what = (( ( (cyear-1)*365) + (  (cyear-1)/4) - (  (cyear-1)/100) + (  (cyear-1)/400)) %7)+1;
		//String day;
		//int[] month;{
			//System.out.print(cyear + "년 1월의 달력");
			
			Scanner sc = new Scanner(System.in);
			
			System.out.println("몇년도 인가요?");
			year = sc.nextInt();
			System.out.println("몇월달 인가요");{
				month = sc.nextInt();
			//System.out.println("                        " + year + "년   " + month + "월");
			}
			
				 if((cyear%4 ==0&& cyear %100 !=0)
				 			||cyear%400 == 0){
					 ++leapyear;
				 }
				 			
				 			
				 	//총일수 계산한 후 7로 나누어 나머지 계산
				 			myday = ((cyear*365)+leapyear) %7;
				 			
				 			//System.out.println("서기 1-12-31의 요일은 " + myday);
				 			
				 			//윤년 횟수 계산
				 			
				 	//만일, 2014-12-31의 요일은?
				 			cyear = 0;
				 			leapyear = 0;
				 			
				 			for(int i = 1;i<=cyear;++i){
				 				
				 			if(i%4 ==0 &&i % 100 !=0 || i % 400 ==0){
				 				++leapyear;
				 			}
			 			}
				 			//윤년 계산
				 			
				 			myday = ((cyear*allday) + leapyear) %7;
				 			//System.out.println("서기 2014-12-31의 요일은" + myday);

				 			System.out.println(myday);
				 			System.out.println(cyear);
				 			System.out.println(allday);
				 			System.out.println(leapyear);
				 		
				 			if(month >=1 && month<=12){				
				 			
				 			
				 
				 			//달력 출력
				 			String result = "\n\t\t\t" + year ;
				 			result += " 년" + month +"월" + "\n";
				 			result +="\t-------------------------------------------------\n";
				 			result +="\t일\t월\t화\t수\t목\t금\t토\n";
				 			
				 			//줄바꿈 처리를 위한 변수
				 			int linecount = 0;
				 			//공백처리
				 			
				 			System.out.println(myday);
				 			if(myday>0){
				 				for(int j=0;j<=myday;++j){
				 					result +="\t";
				 				++linecount;
				 				}
				 			}
				 			
				 			//날짜출력
				 			for(year =1;year <=31;++year){
				 				result += "\t" + year;
				 				 ++linecount;
				 				if(linecount %7==0)
				 					result += "\n";
				 			}
				 			
				 			
				 			System.out.println(result);
				 			
			
			
			}else{
				System.out.println( "잘못입력햇네");
			};
			
		sc.close();
	}//main

}//class
